var t = getApp();

Page({
    data: {
        invoice_id: "",
        language: "",
        detailData: {},
        invoiceType: "",
        orderGoods: [],
        steps: [ "订单提交", "订单完成", "开票完成" ],
        stepIndex: 1,
        show: !1,
        email: ""
    },
    onLoad: function(t) {
        this.setData({
            invoice_id: t.invoice_id
        }), this.getInvoiceDetail();
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    getInvoiceDetail: function() {
        var e = this, a = t.getNetAddresss("plugin.invoice.frontend.index.details");
        t._getNetWork({
            url: a,
            data: {
                id: this.data.invoice_id
            },
            success: function(a) {
                var i, n = a.data;
                if (1 !== n.result) return t.tips(n.msg);
                var s = [];
                s = 1 == n.data.event ? [ "订单提交", "订单完成", "开票完成" ] : [ "订单提交", "订单付款", "开票完成" ], 
                e.setData({
                    detailData: n.data,
                    invoiceType: n.data.invoice_type,
                    orderData: n.data.has_one_order,
                    orderGoods: null === (i = n.data.has_one_order) || void 0 === i ? void 0 : i.has_many_order_goods,
                    stepIndex: n.data.order_invoice_status,
                    steps: s
                });
            }
        });
    },
    showEditEmail: function() {
        this.setData({
            show: !0
        });
    },
    hideEditEmail: function() {
        this.setData({
            show: !1,
            email: ""
        });
    },
    changeEmail: function(t) {
        this.setData({
            email: t.detail.value
        });
    },
    enterFun: function(e) {
        var a = this;
        if (t._isTextEmpty(this.data.email)) return t.tips("发送邮箱不能为空");
        var i = t.getNetAddresss("plugin.invoice.frontend.index.go-email");
        t._getNetWork({
            url: i,
            data: {
                email: this.data.email,
                invoice_sn: this.data.detailData.invoice_sn
            },
            success: function(e) {
                var i = e.data;
                t.tips(i.msg), 1 == i.result && a.hideEditEmail();
            }
        });
    },
    preview: function(t) {
        var e = t.currentTarget.dataset.src;
        wx.previewImage({
            current: e
        });
    },
    downpdf: function(e) {
        var a = e.currentTarget.dataset.download_url;
        if (t._isTextEmpty(a)) return t.tips("暂无发票！");
        wx.downloadFile({
            url: a,
            success: function(e) {
                var a = e.tempFilePath;
                wx.openDocument({
                    filePath: a,
                    success: function() {
                        t.tips("文件打开成功");
                    },
                    fail: function() {
                        t.tips("打开文件失败");
                    }
                });
            },
            fail: function(t) {
                console.log(t, "是失败"), wx.showModal({
                    content: "下载失败，请重新下载"
                });
            }
        });
    },
    noop: function() {},
    onShareAppMessage: function() {}
});